#include "sphere.h"
#include "../math/transform3f.h"

namespace ray_tracing
{
	sphere_t::sphere_t(scene_object_t* in_parent, const pnt3f& origin, float R, material_t* in_material)
		: scene_object_t(in_parent, in_material)
	{
		math_sphere = sphere3fc(origin, R);
	}

	collision::collision_info_t sphere_t::intersect_with(const ray3f& ray, hit_param)
	{
		pnt3f new_origin = transform(get_world_matrix(), math_sphere.origin);
		sphere3f transformed_sphere = sphere3fc(new_origin, math_sphere.R);
		return collision::test_collision(ray, transformed_sphere);
	}
}